//
// Created by zhupi on 2024/9/6.
//

#include "main_window_file.h"

MainWindowMenuBar::MainWindowMenuBar(QWidget *parent) : QMenuBar(parent) {

}

void MainWindowMenuBar::Initial() {
    QMenu *file = new QMenu("File");
    FixedWidthStyle *fixedStyle = new FixedWidthStyle(80); // 设置宽度为 80
    file->setStyle(fixedStyle);
    file->addAction(new QAction("Open"));
    file->addAction(new QAction("Save"));
    file->addAction(new QAction("Project"));
    file->addAction(new QAction("Current"));

    file->setFixedWidth(80);
    this->addMenu(file);



    QMenu * view = new QMenu("View");
    this->addMenu(view);
    QMenu * Project = new QMenu("Project");
    this->addMenu(Project);
    QMenu * help = new QMenu("Help111111111");
    this->addMenu(help);

    view->menuAction()->setProperty("customWidth", 120);
    Project->menuAction()->setProperty("customWidth", 120);
    help->menuAction()->setProperty("customWidth", 120);

    // 设置样式表，使宽度生效
    this->setStyleSheet(R"(
    QMenuBar::item {
        padding: 5px;
    }
    QMenu {
        padding: 5px;
    }
    QMenuBar::item[customWidth] {
        min-width: 120px;
        max-width: 120px;
    }
)");
}
